Skip to content

gh-130821: Add type info to error messages for __len__ and __sizeof__#151894

Closed
tangyuan0821 wants to merge 2 commits into
python:mainfrom
tangyuan0821:130821
Closed

gh-130821: Add type info to error messages for __len__ and __sizeof__#151894
tangyuan0821 wants to merge 2 commits into
python:mainfrom
tangyuan0821:130821

Conversation

@tangyuan0821

@tangyuan0821 tangyuan0821 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Update two more ValueError messages to use the consistent format established in PR #130835 (commit 968f6e5), which added %T type prefix and normalized should → must for invalid return type errors. These two locations were not covered by the original PR or the subsequent follow-ups #144827 and #144737.

Changes:

  • Objects/typeobject.c — slot_sq_length: "len() should return >= 0" → "%T.len() must return >= 0"
  • Python/sysmodule.c — sizeof error: "sizeof() should return >= 0" → "%T.sizeof() must return >= 0"

@StanFromIreland

Copy link
Copy Markdown
Member

Hello @tangyuan0821 the other PR you noted, #144827, is still open, I think these could just be added to it? In the future, I suggest reviews on open PRs, rather than opening new ones for these kinds of things.

@tangyuan0821

Copy link
Copy Markdown
Contributor Author

@StanFromIreland Thanks for the suggestion! I didn't notice that #144827 was still open. I'll close this PR now, and next time I'll make sure to review existing PRs first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants